package com.zr.serviceImpl;

import java.util.Iterator;
import java.util.List;

import com.zr.dao.HRDaodtp;
import com.zr.daoImpl.HRDaoImpldtp;
import com.zr.model.Leave;
import com.zr.service.HRServicedtp;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

public class HRServiceImpldtp implements HRServicedtp{
	HRDaodtp hrdao=new HRDaoImpldtp();
	//增加员工
	@Override
	public int addUser(String ename,int eage,String esex,String enation,String eidcard,String eaddress,String eeducation,String eintime,String eposition,String eremark,int did,String ephone){
		return hrdao.addUser(ename, eage, esex, enation, eidcard, eaddress, eeducation, eintime, eposition, eremark, did, ephone);
		
	}
	//部门下拉框
	@Override
	public JSONArray findSelectDid() {
		JSONArray jarr=new JSONArray();
		List<String> li=hrdao.getSelectDid();
		for(int i=0;i<li.size();i++){
			JSONObject jobj=new JSONObject();
			jobj.put("id",i);
			jobj.put("text",li.get(i));
			jarr.add(jobj);
		}
		return jarr;
	}
	//职位变更信息显示
	@Override
	public JSONObject findEmpls(int page, int rows,String  name) {
		JSONObject jobj=new JSONObject();
		jobj.put("total", hrdao.getEmplsCount(name));
		jobj.put("rows", hrdao.getEmpls(page, rows,name));
		return jobj;
	}
	//职位变更
	@Override
	public boolean changeJob(int eid,String departement, String position) {
		// TODO Auto-generated method stub
		return hrdao.ChangeJob(eid, departement, position);
	}
	//请假
	@Override
	public JSONObject findLeaves(int page, int rows,String state) {
		JSONObject json=new JSONObject();
		json.put("total", hrdao.getLeavesCount(state));
		json.put("rows", hrdao.getleaves(page, rows,state));
		return json;
	}
	//删除员工
	@Override
	public boolean delEmpl(int eid) {
		// TODO Auto-generated method stub
		return hrdao.delEmpl(eid);
	}
	@Override
	public JSONObject findListById(int id) {
		// TODO Auto-generated method stub
		JSONObject json=new JSONObject();
		json.put("applyVacation", hrdao.getListById(id));
		return json;
	}
	@Override
	public boolean subVacation(int id, String opinion, String retime, String remake) {
		// TODO Auto-generated method stub
		return hrdao.subVacation(id, opinion, retime, remake);
	}
	@Override
	public JSONObject findAllData(int page, int rows,String name) {
		JSONObject json=new JSONObject();
		json.put("total", hrdao.findAllCount(name));
		json.put("rows", hrdao.getAll(page, rows,name));
		return json;
	}
	@Override
	public boolean editEmpl(int eid, String mname, int mage, String meducation, String mdizi, String mphone) {
		// TODO Auto-generated method stub
		return hrdao.editEmpl(eid, mname, mage, meducation, mdizi, mphone);
	}
	@Override
	public JSONObject findResign(String state, int page, int rows) {
		JSONObject json=new JSONObject();
		json.put("total", hrdao.resignCount(state));
		json.put("rows", hrdao.getResign(state, page,rows));
		return json;
	}
	@Override
	public JSONObject findResignData(int id) {
		// TODO Auto-generated method stub
		JSONObject json=new JSONObject();
		json.put("re",hrdao.getResignData(id));
		return json;
	}
	@Override
	public boolean checkResign(int id, String opinion, String retime, String remark) {
		// TODO Auto-generated method stub
		return hrdao.checkResign(id, opinion, retime, remark);
	}
	



}
